#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <fstream>
using namespace std;

void z_func(string& s, vector<int>& a)
{
    a.clear();
    a.resize(s.length());
    int l = -1;
    int r = -1;
    for (int i = 1; i < s.length(); ++i)
    {
        if (i < r)
            a[i] = min(a[i - l], r - i);
        else
            a[i] = 0;
        int j = i + a[i];
        while (j < s.length() && s[j] == s[j - i])
        {
            ++a[i];
            ++j;
        }
        if (j > r && a[i])
        {
            l = i;
            r = j;
        }
    }
}

int main()
{
    freopen("input.txt", "r", stdin);
    string s;
    string s1;
    getline(cin, s);
    getline(cin, s1);
    vector<int> a;
    z_func(s1, a);
    int l = -1;
    int r = -1;
    vector<int> res(s.length());
    for (int i = 0; i < s.length(); ++i)
    {
        if (i < r)
            res[i] = min(a[i - l], r - i);
        else
            res[i] = 0;
        int j = i + res[i];
        while(j < s.length() && res[i] < s1.length() && s[j] == s1[j - i])
        {
            ++j;
            ++res[i];
        }
        if (j > r && res[i])
        {
            r = j;
            l = i;
        }
    }
    for (int i = 0; i < res.size(); ++i)
    {
        if (res[i] == s1.length())
        {
            cout<<i;
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}
